<script setup>
import { ref, onBeforeMount } from 'vue'
import CreateOrEdit from './CreateOrEdit.vue'
import { getStatefulSetDetailHandler as getDetail } from '../../api/statefulset.js';
import { useRoute } from 'vue-router'
import { useItem } from '../../store/index.js'
const route = useRoute()
const useItemer = useItem()
let showEdit = ref(false)
// 获取当前编辑的资源配置
onBeforeMount(async () => {
  const requestQuery = route.query // 获取请求参数
  await getDetail(requestQuery).then((res) => {
    console.log('获取资源配置',res.data.data.item)
    useItemer.item = JSON.parse(JSON.stringify(res.data.data.item))// 赋值给pinia
    if (useItemer.item.spec.updateStrategy.type =='RollingUpdate' && useItemer.item.spec.updateStrategy.rollingUpdate == undefined) {
      useItemer.item.spec.updateStrategy.rollingUpdate = {}
    }
    showEdit.value = true
  })
})
</script>

<template>
  <!-- <CreateOrEdit method="Update" v-if="showEdit" resource-type="StatefulSet"></CreateOrEdit> -->
  <CreateOrEdit :method="route.query.method" v-if="showEdit" resource-type="StatefulSet"></CreateOrEdit>
</template>

<style scoped>
</style>
